﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_List_image : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Convert.ToString(Session["Dangnhap"]) == "")
            Response.Redirect("~/Admin/Login.aspx");

        else
            Response.Write("Xin chào " + Convert.ToString(Session["Dangnhap"]));
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        SqlDataSource1.Delete();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/Admin/Add_pictures.aspx");
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Label3.Visible = true;
        Label4.Visible = true;
        Label5.Visible = true;
        Label6.Visible = true;
        Label7.Visible = true;
        txtCaption.Visible = true;
        ddlAlbumID.Visible = true;
        ddlUpID.Visible = true;
        Calendar.Visible = true;
        FileUpload.Visible = true;
        Button4.Visible = true;
        Label1.Visible = true;

    }

    protected void GridView1_SelectedIndexChanged1(object sender, EventArgs e)
    {
        txtPicID.Text = HttpUtility.HtmlDecode(GridView1.Rows[GridView1.SelectedIndex].Cells[1].Text);
        txtCaption.Text = HttpUtility.HtmlDecode(GridView1.Rows[GridView1.SelectedIndex].Cells[3].Text);
        ddlAlbumID.SelectedValue = HttpUtility.HtmlDecode(GridView1.Rows[GridView1.SelectedIndex].Cells[2].Text);
        ddlUpID.SelectedValue = HttpUtility.HtmlDecode(GridView1.Rows[GridView1.SelectedIndex].Cells[6].Text);
        //FileUpload. = HttpUtility.HtmlDecode(GridView1.Rows[GridView1.SelectedIndex].Cells[2].Text);
       
    }
    private void SaveFileUpload()
    {
        string strFilename;
        if (FileUpload.FileName != "")
        {
            strFilename = Server.MapPath("~/App_Data/upload/Picture\\" + FileUpload.FileName);
            FileUpload.PostedFile.SaveAs(strFilename);
        }
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        SqlDataSource1.Update();
        SaveFileUpload();
    }
}
